%initialize variables
testing_pool = matrix_test;
entire_pool = [matrix_base_train; matrix_base_activepool];

%parameters
'training model'
final_model = train(entire_pool(:,1), entire_pool(:,2:end));
'allocating feature score space'
feature_scores = spalloc(size(entire_pool, 1), size(entire_pool, 2)-1, nnz(entire_pool(:,2:end)));

'getting feature scores'
parfor n=1:(size(entire_pool,1))
    feature_scores(n, :) = entire_pool(n,2:end) .* final_model.w;
end

'sorting scores'
feature_scores_sorted = sort(feature_scores, 2, 'ascend');

xth_pos = 2;
percentiles = [2.5 10 25 50 75 90 97.5];
prctile(feature_scores_sorted(:,1+xth_pos),percentiles) %distribution of negative
prctile(feature_scores_sorted(:,size(feature_scores_sorted,2)-xth_pos),percentiles) %dist of pos
prctile(max(abs(feature_scores_sorted(:,1+xth_pos)), abs(feature_scores_sorted(:,size(feature_scores_sorted,2)-xth_pos))),percentiles)
